<<<<<<< HEAD
import random
from urllib.request import urlopen

from django.shortcuts import render, HttpResponse
from utils.tencent.sms import send_sms_single
from django.conf import settings


# Create your views here.

def index(req):
    return render(req, 'backend/index.html')


def send_sms(req):
    code = random.randrange(1000, 9999)
    tpl = req.GET.get('tpl')
    template_id = settings.TENCENT_SMS_TEMPLATE.get(tpl)
    if not template_id:
        return HttpResponse('模版不存在')
    res = send_sms_single('18358090678', 1568346, [code, ])
    if res['result'] == 0:
        return HttpResponse('success')
    else:
        return HttpResponse(res['errmsg'])


def spider(req):
    url = 'http://www.baidu.com'
    resp = urlopen(url)
    print(resp.read())
    # with open('my1.html', mode="w") as f:
    #     f.write(resp.read().decode('utf-8'))
    return render(req, 'test.html')
=======
from django.shortcuts import render

# Create your views here.
>>>>>>> 95a4d99edb9f5535b9fe69c91e1db8793b831863
